<template>
	<view>
		<!-- <cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="content">修改昵称</block>
		</cu-custom> -->
		
		<view v-if="pageLoad">
			<form @submit="submit">
				<view class="cu-form-group margin-top">
					<view class="title">旧昵称</view>
					<input :placeholder="nickname"  disabled ></input>
				</view>
				<view class="cu-form-group">
					<view class="title">新昵称</view>
					<input placeholder="请输入新昵称" focus=" true" name="newnickname"></input>
				</view>
				
				
				<view class="padding flex flex-direction">
					<button type="submit" class="cu-btn bg-blue shadow lg" form-type="submit">修改</button>
				</view>
			</form>
		</view>
	</view>
</template>

<script>
	export default {
		data: function() {
			return {
				pageLoad: true,
				pageData: {},
				nickname:uni.getStorageSync('userInfo').nickname || this.$store.getters.userInfo.nickname
			}
		},
		onLoad: function(option) {
			// this.getPage();
		},

		methods: {
			getPage: function() {

			},
			submit: function(e) {
				
				var nickname=e.detail.value.newnickname;
				console.log(nickname)
				uniCloud.callFunction({
					name:"user-center",
					data: {
						action: 'updateNickname',
						params: {
							nickname:nickname
						}
					},
					 
					success:function(e){
						 
						var res=e.result;
						if(res.code!=0){
							uni.showToast({
								title:res.msg
							})
							return false;
						}
						uni.navigateBack({
							
						})
					},
					fail:function(e){
						console.log(e)
					}
				})
			}
		},

	}
</script>

<style>
</style>
